package sk.octopuss.archery.utils;

import java.io.Serializable;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.springframework.context.i18n.LocaleContextHolder;

public class MessagesProvider implements Serializable {
		
		private static final long serialVersionUID = 1L;

		public static String getMessage(final String key) {
			
				return ResourceBundle.getBundle("validation").getString(key);
			
		}

		public static String getAttributeEquivalentName(final String attributeName) {
			String resource = null;
			try {
				resource = ResourceBundle.getBundle("validation", LocaleContextHolder.getLocale()).getString(attributeName);
			} catch (final MissingResourceException e) {
				System.out.println("Can't find resource in messages for key " + attributeName + " --> it doesn\t have to be error, so don\t worry ;-)");
			}
			return resource;
		}
}
